package com.example.xutils1;

import java.io.IOException;
import java.io.InputStream;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.xutils1.NetWortUtils.OnRequestResultListener;

public class MainActivity extends Activity {

	public static final String path = "http://ic.snssdk.com/2/essay/zone/category/data/?category_id=1&level=6&count=20&min_time=1418285889&iid=2483520179&device_id=3079100957&ac=3g&channel=baidu&aid=7&app_name=joke_essay&version_code=317&device_platform=android&device_type=sdk&os_api=14&os_version=4.0.2&openudid=4acf01557c725cb7";
	public static final String baidu = "http://www.baidu.com/";
	public static final String hao123 = "http://www.hao123.com/";

	public static final String post_url = "http://isub.snssdk.com/2/data/item_action/";

	private TextView mTextView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		mTextView = (TextView) findViewById(R.id.tv);

		try {
			InputStream is = getAssets().open("ico.png");
			Bitmap bmp = BitmapFactory.decodeStream(is);

			ImageView img = (ImageView) findViewById(R.id.img);

			img.setImageBitmap(bmp);
			mTextView.setBackgroundDrawable(new BitmapDrawable(bmp));

		} catch (IOException e) {
			e.printStackTrace();
		}

		NetWortUtils.request(post_url, new OnRequestResultListener() {

			@Override
			public void onSuccess(String result) {
				mTextView.setText(result);
			}
		});
	}
}